//
//  VipCollectionViewCell.m
//  AILove
//
//  Created by 甘世清 on 2023/12/27.
//

#import "VipCollectionViewCell.h"

@implementation VipCollectionViewCell
- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        self.contentView.backgroundColor = UIColor.clearColor;
        
        self.bgView = [[UIView alloc]init];
        self.bgView.backgroundColor = SQHexColor(@"#FFFFFF", 0.1);
        self.bgView.layer.cornerRadius = 6;
        self.bgView.clipsToBounds = YES;
        self.bgView.layer.borderColor = SQColor(@"#FAE3A9").CGColor;
        self.bgView.layer.borderWidth = 0;
        [self.contentView addSubview:self.bgView];
        [self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.edges.equalTo(self.contentView).insets(UIEdgeInsetsMake(2, 6, 0, 4));
        }];
        [self.bgView addSubview:self.nameLabel];
        [self.bgView addSubview:self.moneryLabel];
        [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(self.bgView);
            make.top.equalTo(self.bgView).offset(20);
        }];
        [self.moneryLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(self.bgView);
            make.top.equalTo(self.bgView).offset(70);
        }];
    }
    return self;
}
- (void)setModel:(VipModel *)model{
    _model = model;
    if (model.isseleted) {
        self.bgView.layer.borderWidth = 2;
    } else {
        self.bgView.layer.borderWidth = 0;
    }
    self.nameLabel.text = model.name;
    self.moneryLabel.text = [NSString stringWithFormat:@"%@%@",model.prefix,model.price];
    self.moneryLabel.keywords = model.prefix;
    self.moneryLabel.keywordsFont = FONT_MEDIUM(12);
    [self.moneryLabel getLableSizeWithMaxWidth:80];
}

- (UILabel *)moneryLabel{
    if (!_moneryLabel) {
        _moneryLabel = [[UILabel alloc]init];
        _moneryLabel.font = FONT_BOLD(24);
        _moneryLabel.textColor =  SQColor(@"#FAE3A9");
    }
    return _moneryLabel;
}
 
- (UILabel *)nameLabel{
    if (!_nameLabel) {
        _nameLabel = [[UILabel alloc]init];
        _nameLabel.font = FONT_MEDIUM(14);
        _nameLabel.textColor =  SQColorF1F1F1;
        _nameLabel.backgroundColor = UIColor.clearColor;
        _nameLabel.textAlignment = NSTextAlignmentCenter;
    }
    return _nameLabel;
}
@end
